from playwright.sync_api import sync_playwright
import json

with sync_playwright() as p:
    browser = p.chromium.launch(headless=False, args=['--start-maximized'],slow_mo=1000)
    # 加载本地cookies，免登陆
    context = browser.new_context(storage_state="state.json",record_video_dir="videos/")
    context.tracing.start(screenshots=True, snapshots=True, sources=True)
    page = context.new_page()
    # 进入入库单页面
    page.goto("http://172.28.1.3:2460/#/instorage/inbound")
    page.wait_for_timeout(3000)
    path = page.video.path()
    # 输出追踪视频
    context.tracing.stop(path="trace.zip")

    context.close()
    browser.close()